<template>
    <!-- <el-menu @close="handleClose" default-active="2" :collapse="collapsed" collapse-transition router
             :default-active="$route.path" :default-openeds="opends"
             class="el-menu-vertical-demo" background-color="#334157" text-color="#fff" ref="children"
             :collapse-transition="false"
             @select="selectHandler"
             active-text-color="#ffd04b"> -->
    <el-menu @close="handleClose" default-active="2" :collapse="collapsed" collapse-transition router :default-openeds="opends"
            class="el-menu-vertical-demo" background-color="#334157" text-color="#fff" ref="children"
            @select="selectHandler"
            active-text-color="#ffd04b">
        <div v-if="collapsed" class="logobox">
            <img class="logoimg" src="../assets/img/scrm-logo.png" alt="">
        </div>
        <div v-if="!collapsed" class="logobox" style="align-items: center;display: flex;justify-content: center;">
            <img class="logoimg" src="../assets/img/logo.png" alt="" style="height: 50px !important;">
                       <span style="margin-left: 10px;color: #d3d3d3">卓越SCRM</span>
        </div>
        <el-submenu v-for="menu in allmenu" :key="menu.permissionId" :index="menu.permissionId">
            <el-menu-item v-if="menu.permissionIndex == '1'" index="../views/index" slot="title" style="padding-left: 0 !important;">
<!--                <i :class="menu.permissionIcon"></i>-->
                <img :src="require('@/static/menu_image/首页' + indexIcon + '.png')" />
                <span slot="title">{{ menu.permissionName }}</span>
            </el-menu-item>
            <template slot="title" v-else>
                <img v-if="menu.permissionIcon.indexOf('.png') > -1" :src="require('@/static/menu_image/' + menu.permissionIcon)" />
                <i v-else :class="menu.permissionIcon"></i>
                <span>{{ menu.permissionName }}</span>
            </template>
            <!--注释样式显示单列-->
            <el-menu-item-group disabled>
                <el-menu-item v-for="chmenu in menu.children" :index="'/'+chmenu.permissionUrl" :key="chmenu.permissionId"
                              style="padding: 0 !important;background-color:transparent">
                    <!--                    <i class="iconfont" :class="chmenu.permissionIcon"></i>-->
                    <span>{{ chmenu.permissionName }}</span>
                </el-menu-item>
            </el-menu-item-group>
        </el-submenu>
    </el-menu>
</template>
<script>

export default {
    name: 'leftnav',
    data() {
        return {
            collapsed: false,
            indexIcon: "（选中）",
            allmenu: [
                {
                    permissionId: "1",
                    permissionIndex: "1",
                    permissionName: "首页",
                },
                {
                    permissionId: "2",
                    permissionIndex: "2",
                    permissionName: "获客营销",
                    permissionIcon: "获客营销.png",
                    children: [
                        {
                            permissionUrl: "masket/code",
                            permissionId: "21",
                            permissionName: "员工活码",
                        },
                        {
                            permissionUrl: "masket/friends",
                            permissionId: "22",
                            permissionName: "批量加好友",
                        },
                        {
                            permissionUrl: "masket/red",
                            permissionId: "23",
                            permissionName: "发红包",
                        },
                        {
                            permissionUrl: "masket/wheel",
                            permissionId: "24",
                            permissionName: "大转盘",
                        },
                        {
                            permissionUrl: "masket/traceability",
                            permissionId: "25",
                            permissionName: "溯源海报",
                        },
                        {
                            permissionUrl: "masket/fission",
                            permissionId: "26",
                            permissionName: "任务裂变",
                        },
                        {
                            permissionUrl: "masket/offline",
                            permissionId: "27",
                            permissionName: "线下活动",
                        },
                    ]
                },
                {
                    permissionId: "3",
                    permissionIndex: "3",
                    permissionName: "客户管理",
                    permissionIcon: "客户管理.png",
                    children: [
                        {
                            permissionUrl: "customer/clientClue",
                            permissionId: "31",
                            permissionName: "客户线索",
                        },
                        {
                            permissionUrl: "customer/clientSeas",
                            permissionId: "32",
                            permissionName: "客户公海",
                        },
                        {
                            permissionUrl: "customer/clientList",
                            permissionId: "33",
                            permissionName: "客户列表",
                        },
                        {
                            permissionUrl: "customer/clientStage",
                            permissionId: "34",
                            permissionName: "客户阶段",
                        },
                        {
                            permissionUrl: "customer/clientSop",
                            permissionId: "35",
                            permissionName: "客户SOP",
                        },
                        {
                            permissionUrl: "customer/clientMigration",
                            permissionId: "36",
                            permissionName: "客户迁移",
                        },
                        {
                            permissionUrl: "customer/clientMass",
                            permissionId: "37",
                            permissionName: "客户群发",
                        },
                        {
                            permissionUrl: "customer/clientMoments",
                            permissionId: "38",
                            permissionName: "朋友圈",
                        },
                        {
                            permissionUrl: "customer/clientGreeting",
                            permissionId: "39",
                            permissionName: "好友欢迎语",
                        },
                        {
                            permissionUrl: "customer/clientLoss",
                            permissionId: "310",
                            permissionName: "流失客户",
                        },
                        {
                            permissionUrl: "customer/clientBlacklist",
                            permissionId: "311",
                            permissionName: "黑名单",
                        },
                        
                    ]
                },
                {
                    permissionId: "4",
                    permissionIndex: "4",
                    permissionName: "客群运营",
                    permissionIcon: "客群运营.png",
                    children: [
                        {
                            permissionUrl: "custGroup/cGmanage",
                            permissionId: "41",
                            permissionName: "客群管理",
                        },
                        {
                            permissionUrl: "custGroup/groupTag",
                            permissionId: "42",
                            permissionName: "客群标签",
                        },
                        {
                            permissionUrl: "custGroup/sop",
                            permissionId: "43",
                            permissionName: "客群SOP",
                        },
                        {
                            permissionUrl: "custGroup/tagCreate",
                            permissionId: "44",
                            permissionName: "标签建群",
                        },
                        {
                            permissionUrl: "custGroup/unlimited",
                            permissionId: "45",
                            permissionName: "无限拉群",
                        },
                        {
                            permissionUrl: "custGroup/event",
                            permissionId: "46",
                            permissionName: "群事件",
                        },
                        {
                            permissionUrl: "custGroup/welcome",
                            permissionId: "47",
                            permissionName: "群欢迎语",
                        },
                        {
                            permissionUrl: "custGroup/batchSend",
                            permissionId: "48",
                            permissionName: "客户群转发",
                        },
                        {
                            permissionUrl: "custGroup/statistics",
                            permissionId: "49",
                            permissionName: "群统计",
                        },
                    ]
                },
                {
                    permissionId: "5",
                    permissionIndex: "5",
                    permissionName: "内容引擎",
                    permissionIcon: "内容引擎.png",
                    children: [
                        {
                            permissionUrl: "content/promotion",
                            permissionId: "51",
                            permissionName: "内容审核",
                        },
                        {
                            permissionUrl: "content/conversation",
                            permissionId: "52",
                            permissionName: "话术管理",
                        },
                        {
                            permissionUrl: "content/answer",
                            permissionId: "53",
                            permissionName: "问答管理",
                        },
                        {
                            permissionUrl: "content/article",
                            permissionId: "54",
                            permissionName: "文章管理",
                        },
                        {
                            permissionUrl: "content/material",
                            permissionId: "55",
                            permissionName: "素材管理",
                        },
                        {
                            permissionUrl: "content/card",
                            permissionId: "56",
                            permissionName: "名片管理",
                        },
                        {
                            permissionUrl: "content/form",
                            permissionId: "57",
                            permissionName: "表单管理",
                        },
                        {
                            permissionUrl: "content/Program",
                            permissionId: "58",
                            permissionName: "小程序",
                        }
                    ]
                },
                {
                    permissionId: "6",
                    permissionIndex: "6",
                    permissionName: "风控管理",
                    permissionIcon: "风控管理.png",
                    children: [
                        {
                            permissionUrl: "riskControl/sessionArchive",
                            permissionId: "61",
                            permissionName: "会话存档",
                        },
                        {
                            permissionUrl: "riskControl/sessionContent",
                            permissionId: "62",
                            permissionName: "会话内容",
                        },
                        {
                            permissionUrl: "riskControl/illegalRemind",
                            permissionId: "63",
                            permissionName: "违规提醒",
                        },
                        {
                            permissionUrl: "riskControl/deleteRemind",
                            permissionId: "64",
                            permissionName: "删人提醒",
                        },
                        {
                            permissionUrl: "riskControl/customersRemind",
                            permissionId: "65",
                            permissionName: "客群提醒",
                        },
                        {
                            permissionUrl: "riskControl/groupInspection",
                            permissionId: "66",
                            permissionName: "群聊质检",
                        },
                        {
                            permissionUrl: "riskControl/censorship",
                            permissionId: "67",
                            permissionName: "内容审查",
                        }
                    ]
                },
                {
                    permissionId: "7",
                    permissionIndex: "7",
                    permissionName: "数据安全",
                    permissionIcon: "数据安全.png",
                    children: [
                        {
                            permissionUrl: "security/wxFollowUp",
                            permissionId: "71",
                            permissionName: "微信跟进",
                        },
                        {
                            permissionUrl: "security/generalize",
                            permissionId: "72",
                            permissionName: "销售概览",
                        },
                        {
                            permissionUrl: "security/transform",
                            permissionId: "73",
                            permissionName: "转化漏斗",
                        },
                        {
                            permissionUrl: "security/analyze",
                            permissionId: "74",
                            permissionName: "员工分析",
                        },
                        {
                            permissionUrl: "security/content",
                            permissionId: "75",
                            permissionName: "内容营销",
                        },
                        {
                            permissionUrl: "content/card",
                            permissionId: "76",
                            permissionName: "业绩目标",
                        }
                    ]
                },
            ],
            opends: []
        }
    },
    // 创建完毕状态(里面是操作)
    created() {
        if (this.$route.path == "/views/index/index") {
            this.indexIcon = "（选中）"
        } else {
            this.indexIcon = "（未选种）"
        }
        // 获取图形验证码

        // this.$request("/api/roles/getRolesAuthorityById/1_0?id=" + this.$store.getters.getUserInfo.rolesId + "&type=3", "", "GET").then((data) => {
        //     let opends = []
        //     data.rows.map((item) => {
        //         opends.push(item.permissionId)
        //     })
        //     this.opends = opends

        //     this.allmenu = data.rows
        // })
        // 监听
        this.$root.Bus.$on('toggle', value => {
            this.collapsed = !value
        })
    },
    methods: {
        handleClose(key, keyPath) {
            // this.$refs.menus.open(keyPath);
        },
        selectHandler(key) {
            if (key == "/views/index/index") {
                this.indexIcon = "（选中）"
            } else {
                this.indexIcon = "（未选种）"
            }
        }
    }
}
</script>

<style>
/*不显示菜单箭头*/
.el-submenu__icon-arrow {
    display: none;
}

/*不显示鼠标悬浮菜单*/
.el-menu--vertical {
    display: none;
}

</style>

<style>
.el-menu__wrap {
    overflow-y: hidden;
}

::-webkit-scrollbar {
    width: 0px;
}

.el-menu-vertical-demo:not(.el-menu--collapse) {
    width: 240px;
    min-height: 400px;
}

.el-menu-vertical-demo:not(.el-menu--collapse) {
    border: none;
    text-align: left;
}

.el-menu-item-group__title {
    padding: 0px;
}

.el-menu-bg {
    background-color: #1f2d3d !important;
}

.el-menu {
    border: none;
}

.logobox {
    height: 40px;
    line-height: 40px;
    color: #9d9d9d;
    font-size: 20px;
    text-align: center;
    padding: 20px 0px;
}

.logoimg {
    height: 40px;
}
</style>
<style scoped>

/deep/ .el-submenu .el-menu-item {
    height: 50px;
    line-height: 50px;
    padding: 0;
    min-width: 0;
    width: 35%;
    background-color: transparent !important;
}

/deep/ .el-menu-item-group ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    width: 90%;
    margin: 0 5%;
}

/deep/ .el-menu-item-group ul:after {
    content: ' ';
    width: 35%;
    height: 0;
    display: block;
} 
</style>
